<template>
    <div id = "ack">
      activity
      <button @click="func">click</button>
    </div>
</template>

<script>
    export default {
        name: "activity",
      data(){
          return {
            goodsList:[]
          }
      },
      methods:{
          func:function () {
            var _this = this;
            this.$http.get("http://localhost:3000/api/home?sectionId=0&pageNo=1&pageSize=20")
              .then(function(response){
                console.log(response);
                _this.goodsList = response.data.data;
              })
              .catch(function(error){
                console.log(error);
              })
          }
      },
      activated(){
//       keep-alive组件激活时调用。
// 　　该钩子在服务器端渲染期间不被调用。
        console.log("优惠视图激活");
        var _this = this;
        this.$http.get("http://localhost:3000/api/home?sectionId=0&pageNo=1&pageSize=20")
          .then(function(response){
            console.log(response);
            _this.goodsList = response.data.data;
          })
          .catch(function(error){
            console.log(error);
          })
      }
    }
</script>

<style scoped>
  #ack{
    background:red;
  }

</style>
